package com.efamily.ewallet.server;

import com.efamily.authorization.domain.CredentialModel;
import com.efamily.authorization.domain.SSOTicketModel;
import com.efamily.ewallet.client.account.bean.AccountBean;
import com.efamily.ewallet.client.common.bean.UserBean;
import com.efamily.ewallet.client.services.IAuthorizationService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class AuthorizationService extends RemoteServiceServlet implements
		IAuthorizationService {
	
	//DAOFactory  daoFactory = DAOFactory.getInstance();
	public UserBean login(String login, String password) {
		CredentialModel credential = new CredentialModel(login, password);
		//ICredentialDAO credentialDAO = daoFactory.getCredentialDAO();
		SSOTicketModel ticket = new SSOTicketModel();// credentialDAO.login(credential);
		//UserBean(ticket.getUserCredential().getId(), ticket.getUserCredential().getUserName(), ticket.getTicketValue());
		UserBean userBean = new UserBean(1, "123");
		AccountBean account = new AccountBean();
		account.setId(1);
		account.setNickName(login);
		userBean.setAccount(account);
		return userBean;
	}

	public UserBean checkSSO(String cookieValue) {
		//ISSOTicketDAO ticketDAO = daoFactory.getSSOTicketDAO();
		SSOTicketModel ticket = new SSOTicketModel();//ticketDAO.getTicket(cookieValue);
		if(ticket != null){
			return new UserBean(/*ticket.getUserCredential().getId(), ticket.getUserCredential().getUserName()*/);
		}
		return null;
	}
}
